import React, { Component } from 'react'
import styles from './home.module.scss'
import { Button } from 'antd'
import { getWeather } from '@/api/flow.js'

export default class home extends Component {
  state = {
    msg: ''
  }
  
  showData = async () => {
    const data = await getWeather({
      appid: '51771596',
      appsecret: '2djQkmXZ',
      unescape: 1
    })
    this.setState(
      {
        msg: JSON.stringify(data)
      },
      () => {
        console.log(this.state.msg)
      }
    )
  }

  render() {
    const { msg } = this.state;
    return (
      <div>
        <div className={styles.home}>home page</div>
        <Button type='primary' onClick={this.showData}>
          获取接口数据
        </Button>
        <p>{msg}</p>
      </div>
    )
  }
}
